import 'package:ultralytics_yolo/yolo.dart';
import 'package:flutter/material.dart';
import 'package:WherFire/model_manager.dart';


void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'WherFire',
      theme: ThemeData(
        useMaterial3: true,
        colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xA7B28EFF)),
      ),
      home: TestYOLO(),
    );
  }
}

class TestYOLO extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('YOLO Test')),
      body: Center(
        child: ElevatedButton(
          child: Text('Test YOLO'),
          onPressed: () async {
            try {
              final yolo = YOLO(
                modelPath: model_load.$modelPath,
                task: YOLOTask.detect,
              );

              await yolo.loadModel();
              print('✅ YOLO loaded successfully!');

              ScaffoldMessenger.of(context).showSnackBar(
                SnackBar(content: Text('YOLO plugin working!')),
              );
            } catch (e) {
              print('❌ Error: $e');
              ScaffoldMessenger.of(context).showSnackBar(
                SnackBar(content: Text('Error: $e')),
              );
            }
          },
        ),
      ),
    );
  }
}